<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>返回当前的 Unix 时间戳</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.strtotime.html">strtotime</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.timezone-abbreviations-list.html">timezone_abbreviations_list</a></div>
 <div class="up"><a href="ref.datetime.html">Date/Time 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.time" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">time</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">time</span> &mdash; <span class="dc-title">返回当前的 Unix 时间戳</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.time-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">int</span> <span class="methodname"><strong>time</strong></span>
    ( <span class="methodparam">void</span>
   )</div>

  <p class="para rdfs-comment">
   返回自从 Unix 纪元（格林威治时间 1970 年 1 月 1 日 00:00:00）到当前时间的秒数。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.time-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2260">
    <p><strong>Example #1 <span class="function"><strong>time()</strong></span> 例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$nextWeek&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">time</span><span style="color: #007700">()&nbsp;+&nbsp;(</span><span style="color: #0000BB">7&nbsp;</span><span style="color: #007700">*&nbsp;</span><span style="color: #0000BB">24&nbsp;</span><span style="color: #007700">*&nbsp;</span><span style="color: #0000BB">60&nbsp;</span><span style="color: #007700">*&nbsp;</span><span style="color: #0000BB">60</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;7&nbsp;days;&nbsp;24&nbsp;hours;&nbsp;60&nbsp;mins;&nbsp;60secs<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">'Now:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'Y-m-d'</span><span style="color: #007700">)&nbsp;.</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">'Next&nbsp;Week:&nbsp;'</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'Y-m-d'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$nextWeek</span><span style="color: #007700">)&nbsp;.</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">//&nbsp;or&nbsp;using&nbsp;strtotime():<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">'Next&nbsp;Week:&nbsp;'</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'Y-m-d'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">'+1&nbsp;week'</span><span style="color: #007700">))&nbsp;.</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Now:       2005-03-30
Next Week: 2005-04-06
Next Week: 2005-04-06
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.time-notes">
  <h3 class="title">注释</h3>
  <div class="tip"><strong class="tip">Tip</strong>
   <p class="para">
    自 PHP 5.1 起在 <var class="varname"><var class="varname"><a href="reserved.variables.server.html" class="classname">$_SERVER['REQUEST_TIME']</a></var></var>
    中保存了发起该请求时刻的时间戳。
   </p>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.time-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.date.html" class="function" rel="rdfs-seeAlso">date()</a> - 格式化一个本地时间／日期</span></li>
    <li class="member"><span class="function"><a href="function.microtime.html" class="function" rel="rdfs-seeAlso">microtime()</a> - 返回当前 Unix 时间戳和微秒数</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.strtotime.html">strtotime</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.timezone-abbreviations-list.html">timezone_abbreviations_list</a></div>
 <div class="up"><a href="ref.datetime.html">Date/Time 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
